﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Entities;
using Business;
using DevComponents.DotNetBar;
namespace Presentation
{
    public partial class frmLapBaoCaoTon : DevComponents.DotNetBar.Office2007Form
    {
        public frmLapBaoCaoTon()
        {
            InitializeComponent();
        }

        private void frmLapBaoCaoTon_Load(object sender, EventArgs e)
        {
            dtiThang.Value = DateTime.Now;
        }

        private void btnLapBaoCao_Click(object sender, EventArgs e)
        {
            DateTime date = dtiThang.Value;
            string thang = date.Month.ToString() + "-" + date.Year.ToString();
            DataTable dt = BaoCaoTonService.LapBaoCao(dtiThang.Value);
            if (dt == null)
            {
                MessageBoxEx.Show("Không tồn tại dữ liệu cho tháng "+thang, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            CrystalDecisions.CrystalReports.Engine.TextObject objThang;
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpdoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();


            rpdoc.Load(Application.StartupPath + @"\rpBaoCaoTon.rpt");

            objThang = (CrystalDecisions.CrystalReports.Engine.TextObject)rpdoc.ReportDefinition.Sections[0].ReportObjects["Thang"];
            objThang.Text = thang;
            rpdoc.SetDataSource(dt);
            rpvBaoCaoTon.ReportSource = rpdoc;
        }
    }
}
